package org.bigmarketapi.projectreview.DesingMode.CompositeMode.Basic.Filter;

import org.bigmarketapi.projectreview.DesingMode.CompositeMode.Basic.model.treeNode;
import org.bigmarketapi.projectreview.DesingMode.CompositeMode.Basic.model.treeNodeLine;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @BelongsProject: ProjectReview
 * @BelongsPackage: org.bigmarketapi.projectreview.DesingMode.CompositeMode.Filter
 * @Author: dujiaqi
 * @CreateTime: 2024-08-14  16:11
 * @Description: TODO
 * @Version: 1.0
 */
@Service
public abstract class baseLogic implements  logicFilter{
    @Override
    public Integer filter(String matterValue, treeNode node) {
        final List<treeNodeLine> lineList = node.getTreeNodeLineList();
        final treeNodeLine treeNodeLine = lineList.stream().filter(s -> makeDecisionMap(matterValue, s)).findFirst().orElse(null);
       return  treeNodeLine==null? null:treeNodeLine.getTreeTargetId();
    }
    public boolean makeDecisionMap(String matterValue,treeNodeLine nodeLine){
        //根据limitedType指向到达的值
        final String lineValue = nodeLine.getNodeLineValue();
        switch (nodeLine.getRuleLimitType()){
            case 1:
                return matterValue.equals(lineValue);
            default:
                return false;
        }
    }
}
